package top.ranzhang.mapper;

import org.apache.ibatis.annotations.*;
import top.ranzhang.bean.entity.ParentCommunications;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import java.util.List;


@Mapper
public interface ParentCommunicationsMapper extends BaseMapper<ParentCommunications> {

    @Select("SELECT * FROM parent_communications WHERE communication_id = #{id}")
    ParentCommunications selectById(Long id);

    @Select("SELECT * FROM parent_communications")
    List<ParentCommunications> selectAll();

    @Insert("INSERT INTO parent_communications(student_id, contact_person, contact_method, " +
            "content_summary, follow_up_required, next_follow_up_date, staff_id) VALUES " +
            "(#{studentId}, #{contactPerson}, #{contactMethod}, #{contentSummary}, " +
            "#{followUpRequired}, #{nextFollowUpDate}, #{staffId})")
    void MInsert(ParentCommunications communication);

    @Update("UPDATE parent_communications SET student_id=#{studentId}, contact_person=#{contactPerson}, " +
            "contact_method=#{contactMethod}, content_summary=#{contentSummary}, follow_up_required=#{followUpRequired}, " +
            "next_follow_up_date=#{nextFollowUpDate}, staff_id=#{staffId} WHERE communication_id=#{communicationId}")
    void update(ParentCommunications communication);

    @Delete("DELETE FROM parent_communications WHERE communication_id = #{id}")
    void delete(Long id);

    Integer getCommunicationCount();
}
